package org.aldar.bquest.logic.controller.level;

import org.aldar.bquest.constants.LandscapeType;
import org.aldar.bquest.entity.AbilityTileSprite;
import org.aldar.bquest.entity.CloudSettings;
import org.aldar.bquest.entity.LandscapeArea;
import org.aldar.bquest.entity.ManaSettings;
import org.aldar.bquest.logic.GameTutorial;

import java.util.LinkedList;
import java.util.List;

/**
 * User: Daria
 * Date: 9/22/14 12:44 PM
 */
public class LevelAreaDef {

    public List<LandscapeType> lsTypesTimeline;
    public List<LandscapeType> lsTypesBoard;

    private AbilityTileSprite.AbilityType[] abilityTypes = new AbilityTileSprite.AbilityType[]{
            AbilityTileSprite.AbilityType.MOVE_HERO,
            AbilityTileSprite.AbilityType.MISSILE,
            AbilityTileSprite.AbilityType.EXPLODE_9
    };

    private ManaSettings manaSettings;

    private LandscapeArea[] landscapeAreas;

    private GameTutorial.TutorialSection[] sectionsToShow;

    private int length;

    private int numberOfTowns;

    private int minLandscapeLength;

    private int maxLandscapeLength;

    private int movesAllowed;

    private float[] levelMapCoords;

    private CloudSettings cloudSettings;

    private int costMoneyToUnlock;
    private int costFameToUnlock;

    public Integer getPreviousLevelAreaIndex() {
        return previousLevelAreaIndex;
    }

    private Integer previousLevelAreaIndex;

    private List<LevelDef> areaLevels = new LinkedList<LevelDef>();

    public LevelAreaDef(Integer levelAreaIndex, Integer previousLevelAreaIndex, int costMoneyToUnlock, int costFameToUnlock, int numberOfLevels, float[] levelMapCoords, LandscapeType[] lsTypesBoard, LandscapeType[] lsTypesTimeline) {
        this.lsTypesBoard = new LinkedList<LandscapeType>();
        for (LandscapeType lsType : lsTypesBoard) {
            this.lsTypesBoard.add(lsType);
        }
        if (lsTypesTimeline == null) {
            this.lsTypesTimeline = this.lsTypesBoard;
        } else {
            this.lsTypesTimeline = new LinkedList<LandscapeType>();
            for (LandscapeType lsType : lsTypesTimeline) {
                this.lsTypesTimeline.add(lsType);
            }
        }
        this.levelMapCoords = levelMapCoords;
        this.previousLevelAreaIndex = previousLevelAreaIndex;
        this.costFameToUnlock = costFameToUnlock;
        this.costMoneyToUnlock = costMoneyToUnlock;

        for (int i = 0; i < numberOfLevels; i++) {
            LandscapeType[] lsTypesLevel = LevelDefinition.lsTypesByLevel.get(levelAreaIndex + "_" + i);
            LevelDef level = new LevelDef(
                    LevelDefinition.levelDefs.get(levelAreaIndex + "_" + i),
                    lsTypesLevel != null ? lsTypesLevel : lsTypesBoard,
                    LevelDefinition.enemyIndicesByLevel.get(levelAreaIndex + "_" + i),
                    LevelDefinition.abilityTypesByLevel.get(levelAreaIndex + "_" + i)
            );
            areaLevels.add(level);
        }
    }


    public float[] getLevelMapCoords() {
        return levelMapCoords;
    }

    public List<LevelDef> getAreaLevels() {
        return areaLevels;
    }

    public int getCostFameToUnlock() {
        return costFameToUnlock;
    }

    public int getCostMoneyToUnlock() {
        return costMoneyToUnlock;
    }
}
